#pragma once
#include "RBTree.hpp"

namespace yiwei
{
	template<class K>
	class set
	{
		struct SetKeyOfT
		{
			const K& operator()(const K& key)
			{
				return key;
			}
		};
	public:
		typedef typename RBTree<K, K, SetKeyOfT>::iterator iterator;
		typedef typename RBTree<K, K, SetKeyOfT>::const_iterator const_iterator;

		set(){}

		set(const set& s)
			:_t(s._t)
		{}

		set& operator=(set s)
		{
			std::swap(_t, s._t);
			return *this;
		}

		std::pair<iterator,bool> insert(const K& key)
		{
			return _t.Insert(key);
		}

		iterator find(const K& key)
		{
			return _t.Find(key);
		}

		void erase(iterator pos)
		{
			_t.Erase(pos);
		}

		void clear()
		{
			_t.Clear();
		}
		iterator begin()
		{
			return _t.begin();
		}

		iterator end()
		{
			return _t.end();
		}

		bool IsValidRBTree()
		{
			return _t.IsValidRBTree();
		}

	private:
		RBTree<const K, K, SetKeyOfT> _t;
	};
}